package com.ccit.greenlife.controller;

import com.ccit.greenlife.pojo.PageBean;
import com.ccit.greenlife.pojo.Result;
import com.ccit.greenlife.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/product")
public class ProductController {
    @Autowired//Spring 容器在创建对象时会自动注入相应的依赖
    private ProductService productService;

    //返回商品集合（分页）
    @GetMapping("/all")
    public Result<PageBean> getPagesProducts(@RequestParam(defaultValue = "1") Integer page, @RequestParam(defaultValue = "10")Integer pageSize, String type, String name){
        System.out.println("当前页码" + page );
        System.out.println("当前请求的数据的数量" + pageSize);
        System.out.println("名字" + name );
        System.out.println("类型" + type);
        PageBean pageBean =  productService.getAllProducts(page, pageSize, type, name);
        return Result.success(pageBean);
    }
}
